Saves a region relative to a window, control, or the test computer screen as a PNG file. Use when debugging OCR statements.
For example, if you use the OCRGetText statement to get text from a web page and then set the returned text in the Username editbox, you can use this statement to save an image of the specified area the text was returned from. If log in fails, you can use the saved image to help determine if the correct Username value was entered. See Using OCR to Work with Graphical Text.
Syntax
SaveRegionToImageFile("FilePath", LeftEdgePixel, RightEdgePixel, RectangleWidth, RectangleHeight)
Arguments
Argument | Description |
---|---|
FilePath | Full path including filename to save the image in. If the path does not include a .png extension, it is added when saving the image. See Identifying files and directories in statements for information about configuring full paths relative to the workspace or script directory. |
LeftEdgePixel | Optional integer pixel value of the left side of the rectangle that contains the region to save. If not specified, an image of the entire window, control, or test computer screen is saved. Required if the TopEdgePixel, RectangleWidth, or RectangleHeight argument is specified. |
TopEdgePixel | Optional integer pixel value of the top side of the rectangle that contains the region to save. If not specified, an image of the entire window, control, or test computer screen is saved. Required if the LeftEdgePixel, RectangleWidth, or RectangleHeight argument is specified. |
RectangleWidth | Optional integer pixel value of the width of the rectangle that contains the region to save. If not specified, an image of the entire window, control, or test computer screen is saved. Required if the LeftEdgePixel, TopEdgePixel, or RectangleHeight argument is specified. |
RectangleHeight | Optional integer pixel value of the height of the rectangle that contains the text to verify. If not specified, an image of the entire window, control, or test computer screen is saved. Required if the LeftEdgePixel, TopEdgePixel, or RectangleWidth argument is specified. |
Supported objects
Browser, Button, Calendar, Cell, CheckBox, ColumnHeader, ComboBox, ContextMenu, Control, DateTimePicker, EditBox, Grid, HTMLElement, HTMLLink, HTMLTable, Image, Item, Label, Link, ListBox, ListView, Menu, NavigationField, PopupMenu, ProgressBar, RadioButton, Row, RowHeader, ScrollBar, Slider, SpinBox, SubItem, Tab, TabBar, ToolBar, Tree, Window
Example
If (Not Window("WysiCorp Report a Bug").EditBox("editboxSummary").WaitForExists(1000)) Then
Script.CloseApp()
Script.RunApp()
'Saves an image of the region OCR was performed on for debugging purposes
Window("WysiCorp Home").HTMLElement("elementLoginTester").SaveRegionToImageFile("C:\\OCRTests\\Images\\DebugPassword.png", 80, 31, 61, 17)
End If